import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store =  new Vuex.Store({
  state: {
    author:'Damon',
    canGoOn:true, //是否可以继续发送请求
    public_bc:false, //公共遮挡层
    public_bc_main:false, //main公共遮挡层
    webSocketTime:'', //webSocket的更新的时间
    webSocketText:'', //webSocket的更新的类别
    newOrderNum:'', //订单数量
    newCallNum:0, //呼叫数量
    TDshow:false, //公共的过渡
    TTDshow:false, //公共的过渡
    lockTran:false, //公共的过渡（锁定）
    lockShow:false, //公共的过渡（锁定）
    public_is_Loading:false, //公共的加载判定
    realTimeSwich:false, //是否点击实时房态的房间(如果点击，今日房价消失，远期房态和房务管理出现，反之亦然)
    publicOrderInfo:[], //预定房间时生成的订单信息
    payInfo:[], //订单支付信息
    publicRoomsList:[], //可预订房间列表
    publicRealTimeRoomsList:[], //实时房间列表
    hotelaccounts:[], //收款账户列表
    loginUserInfo:[], //当前登录用户信息
    otaList:[], //当前酒店的OTA列表
    houseNight:1, //预订开房页面的几晚下拉列表
    houseStart:'', //预订开房页面的时间选择
    houseFloor:'全部楼层', //预订开房页面的楼层选择
    houseWindow:'2', //预订开房页面的房间规格(窗户)选择
    houseStatus:'0', //预订开房页面的房间状态选择
    houseType:'0', //预订开房页面的房间类型选择
    realTimeChooseRoom:[], //实时房态选择的房间
    realTimeChooseRoomNo:'', //实时房态选择的房间房号
    publicScreen:[], //公共的订单列表筛选条件
    saveHouseList:[], //添加入订单确认列表的房间
    jzPrint:[], //明细打印
    agreement_customers:[], //协议客户列表
    agreement_projects:[], //协议客户方案
    oldList:[], //协议客户老的房价列表
    loopStop:false, //跑马灯停止运行
    showBar:false, //酒店吧显示
    canRefresh:false, //刷新订单详情
  },
  getters: { // 暴露值到外部
    author : state => state.author,
    canGoOn : state => state.canGoOn,
    webSocketTime : state => state.webSocketTime,
    webSocketText : state => state.webSocketText,
    newCallNum : state => state.newCallNum,
    newOrderNum : state => state.newOrderNum,
    public_bc : state => state.public_bc,
    public_bc_main : state => state.public_bc_main,
    TDshow : state => state.TDshow,
    TTDshow : state => state.TTDshow,
    lockTran : state => state.lockTran,
    lockShow : state => state.lockShow,
    public_is_Loading : state => state.public_is_Loading,
    realTimeSwich : state => state.realTimeSwich,
    publicOrderInfo : state => state.publicOrderInfo,
    payInfo : state => state.payInfo,
    publicRoomsList : state => state.publicRoomsList,
    publicRealTimeRoomsList : state => state.publicRealTimeRoomsList,
    hotelaccounts : state => state.hotelaccounts,
    loginUserInfo : state => state.loginUserInfo,
    otaList : state => state.otaList,
    houseNight : state => state.houseNight,
    houseStart : state => state.houseStart,
    houseFloor : state => state.houseFloor,
    houseWindow : state => state.houseWindow,
    houseStatus : state => state.houseStatus,
    houseType : state => state.houseType,
    realTimeChooseRoom : state => state.realTimeChooseRoom,
    realTimeChooseRoomNo : state => state.realTimeChooseRoomNo,
    publicScreen : state => state.publicScreen,
    saveHouseList : state => state.saveHouseList,
    jzPrint : state => state.jzPrint,
    agreement_customers : state => state.agreement_customers,
    agreement_projects : state => state.agreement_projects,
    oldList : state => state.oldList,
    loopStop : state => state.loopStop,
    showBar : state => state.showBar,
    canRefresh : state => state.canRefresh,
  },
  actions: {
    upstate({commit},keyval){
      commit('UPSTATE',keyval)
    },
    upPush({commit},keyval){
      commit('UPPUSH',keyval)
    },
    otherAction: (context, type) => {
      return true;
    },
    socket_userMessage: (context, message) => {
      context.dispatch('newMessage', message);
      context.commit('NEW_MESSAGE_RECEIVED', message);
      if (message.is_important) {
        context.dispatch('alertImportantMessage', message);
      }
    },
  },
  mutations: {
    //修改功能
    UPSTATE(state,keyval){
      state[keyval.key] = keyval.val
    },
    //数组添加功能
    UPPUSH(state,keyval){
      state[keyval.key].push(keyval.val)
    },
    SOCKET_CONNECT: (state,  status ) => {
      state.connect = true;
    },
    SOCKET_USER_MESSAGE: (state,  message) => {
      state.message = message;
    }
  },
})
export default store
